package com.education.springbootdemo.dao;

import com.education.springbootdemo.mapper.UserMapper;
import com.education.springbootdemo.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDao {

    @Autowired
    private UserMapper userMapper;

    public Long inserUser(final User user) {
        //1、先从数据库中查询是否有同名，
        User u = userMapper.selectByUsername(user.getUsername());
        if(u != null) {
            return 0L;
        }
       return userMapper.insertUser(user);
    }
}
